import QtQuick 2.0

Rectangle {
    id: root
    height:100
    width:200
    property int radiusCorners: Qt.AlignLeft | Qt.AlignRight | Qt.AlignTop | Qt.AlignBottom
    Repeater {
        model: [ {
                x: 0,
                y: 0,
                visible: internal.aligns(Qt.AlignLeft | Qt.AlignTop),
                radius: root.radius
            },
            {
                x: root.width - root.radius,
                y: 0,
                visible: internal.aligns(Qt.AlignRight | Qt.AlignTop),
                radius: root.radius
            },
            {
                x: 0,
                y: root.height - root.radius,
                visible: internal.aligns(Qt.AlignLeft | Qt.AlignBottom),
                radius: root.radius
            },
            {
                x: root.width - root.radius,
                y: root.height - root.radius,
                visible: internal.aligns(Qt.AlignRight | Qt.AlignBottom),
                radius: root.radius
            } ]

        Rectangle {
            id: fillRect
            x: modelData.x; y: modelData.y
            width: modelData.radius; height: width
            visible: !modelData.visible
            color: parent.color
            border.width: root.border.width
            border.color: root.border.color
        }

//        Rectangle {
//            color: fillRect.color
//            border.width: 0
//            anchors.fill: fillRect
//            visible: fillRect.visible
//            onVisibleChanged: {
//                if(visible) {
//                    if(internal.aligns(Qt.AlignLeft | Qt.AlignTop)) {
//                        anchors.rightMargin = 0
//                        anchors.bottomMargin = 0
//                    }
//                }
//            }
//        }


//                        else if(internal.aligns(Qt.AlignRight | Qt.AlignTop)) {
//                            anchors.leftMargin = 0
//                            anchors.bottomMargin = 0
//                        }
//                        else if(internal.aligns(Qt.AlignLeft | Qt.AlignBottom)) {
//                            anchors.rightMargin = 0
//                            anchors.topMargin = 0
//                        }
//                        else if(internal.aligns(Qt.AlignRight | Qt.AlignBottom)) {
//                            anchors.leftMargin = 0
//                            anchors.topMargin = 0
//                        }
//                    }
//                }
            }


//        }
//    }
    QtObject {
        id: internal

        function aligns(direction) {
            return (root.radiusCorners & direction) === direction
        }
    }
}
